import { view } from "cc";

class GameGlobalStatus {
  public static _instance: GameGlobalStatus = null;

  private constructor() {
    let uiScreen = view.getVisibleSize();
    this.uiScreenHeight = uiScreen.height;
    this.uiScreenWidth = uiScreen.width;
  }

  // 游戏状态 0-首页 1-开始 2-暂停
  public gameStatus: number = 0;

  // 天空移动的速度
  public skyMoveSpeed: number = 100;

  // 飞机的等级
  public airPlaneLevel: number = 1;

  // 子弹相关
  public bulletSpeed: number = 5;
  public bulletShootTime: number = 0.3;
  public uiScreenHeight = 0;
  public uiScreenWidth = 0;

  public enemyCreateTime: number = 0.5;

  public static getInstance() {
    if (!this._instance) {
      this._instance = new GameGlobalStatus();
    }
    return this._instance;
  }

  public restGameGlobalStatus() {
    this.gameStatus = 0;
    this.skyMoveSpeed = 100;
    this.airPlaneLevel = 1;
    this.bulletSpeed = 1;
    this.bulletShootTime = 0.3;
  }
}

export const gameGlobalStatus = GameGlobalStatus.getInstance();
